home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 52
/
Amiga Format AFCD52 (Issue 136, May 2000).iso
/
-serious-
/
programming
/
basic
/
mildred
/
mildred.lha
/
lha
/
PixelExplosion4.lha
/
2DPixelExplosion4.ascii
next >
Wrap
Text File
|
1999-03-30
|
4KB
|
120 lines
;Pixel Explosion Mildred Library Example.
;
;Programmed by : Mikkel Loekke, aka. FlameDuck.
;
;Please read the README file.
; __ _
;Modified by Sami Naatanen (25.01.1999)
; Just made it faster and more "realistic"
; Can now do easily 4000 pixels and 060 with 10000 stars is still
; super smooth! In fact 15000 stars runs quite smooth
; (some jerking at the beginning).
;Modified by Paul West (10.2.1999)
; Split point newtypes into two distinct groups
; Implemented particle animation routines, speed is *at least* 200%!!
WBStartup
NoCli
degrad.q = Pi/180
NEWTYPE .point
x.q
y.q
End NEWTYPE
NEWTYPE .point2
anglx.q
angly.q
End NEWTYPE
#numpnts=5000 ; Change this for more or less points.
Dim pnt.point (#numpnts)
Dim pnt2.point2 (#numpnts)
DEFTYPE.l
MCPU Processor ; Tell Mildred which CPU it should use.
Mc2pCPUmode Processor ; Tell Mildred which CPU it should use for c2p.
MReserveBitmaps 1 ; Tell Mildred that we're going to use 1 chunky bitmap.
MReservec2pWindows 1 ; Tell it we only need one c2p display.
MReserveShapes 1 ; Tell Mildred that we need a shape aswell.
InitPalette 0,256 ; Setup a grayscale palette.
For t.l=0To 255
AGAPalRGB 0,t,t,t,t
Next
.initgraphics
MBitmap 0,320,256 ; This will contain our chunky buffer.
Mc2pWindow 0,320,256 ; Setup structures for c2p conversions.
*pbb.l=AllocMem(320*256,$10002) ; Get some free CHIP memory
If *pbb.l ; and if we succeed
CludgeBitMap 0,320,256,8,*pbb ; make it a planar bitmap.
Else End
EndIf
Dim scrtaglst.TagItem(7) ; All this stuff sets up our
scrtaglst(0)\ti_Tag = #SA_Left ; Taglist for the screen we
scrtaglst(0)\ti_Data = 0 ; want.
scrtaglst(1)\ti_Tag = #SA_Depth
scrtaglst(1)\ti_Data = 8
scrtaglst(2)\ti_Tag = #SA_Width
scrtaglst(2)\ti_Data = 320
scrtaglst(3)\ti_Tag = #SA_Height
scrtaglst(3)\ti_Data = 256
scrtaglst(4)\ti_Tag = #SA_BitMap
scrtaglst(4)\ti_Data = Addr BitMap (0)
scrtaglst(5)\ti_Tag = #SA_ShowTitle
scrtaglst(5)\ti_Data = 0
scrtaglst(6)\ti_Tag = #SA_Draggable
scrtaglst(6)\ti_Data = 0
scrtaglst(7)\ti_Tag = #TAG_END ; The most important tag of them all.
ScreenTags 0,"MildredDEMO",&scrtaglst(0) ; Open our intuition screen.
ShowPalette 0 ; Attach our palette to the screen.
Dim cin.q(359),kos.q(359)
For t.l=0 To 359
cin(t)=Sin(degrad*t)
kos(t)=Cos(degrad*t)
Next t
MParticleFormat -1
MParticleMode MAddMode
.goagain ; A Label that tells us where to go
; to reset all our variables
centerx.q=80+Rnd(160)
centery.q=64+Rnd(128)
For t.l=0To #numpnts
pnt(t)\x=centerx
pnt(t)\y=centery
r.w=Rnd(359)
v.q=Rnd(Rnd(4.4)+3)+Rnd(1.6)
pnt2(t)\anglx=cin(r)*v
pnt2(t)\angly=kos(r)*v
Next
phase.w=0
pntskip.w=0
Repeat ; Repeat our mainloop ....
Mc2p *pbb ; Convert our chunky buffer to
MCls
MAddToParticles &pnt(0)\x,#numpnts,&pnt2(0)\anglx
MBitmapClip 0,On
MPlotParticles &pnt(0)\x,#numpnts,20;255-phase
MBitmapClip 0,Off
phase+2:If phase=256 Then pntskip=#numpnts
Until RawStatus($45) OR pntskip=#numpnts ; .... Until we press Escape, or the fade is complete.
If pntskip=#numpnts Then Goto goagain ; If the fade completed, reset variables, and go again.
End ; End our nice program.